#ifndef __FIELD_H
#define __FIELD_H

#include "StdAfx.h"


namespace Database
{
	namespace _xxImpl_MySql
	{
		class Field : public IField
		{
			std::string m_szValue;
		public:
			Field() { m_szValue = ""; }
			void Init(std::string szValue) { m_szValue = szValue; }
			void SetValue(std::string szValue) { m_szValue = szValue; }

			std::string ToString() { return m_szValue; }
			uint64 ToUInt64()
			{
				uint64 value = 0;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return value;
				else
					return 0;
			}
			uint32 ToUInt32()
			{
				uint32 value;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return value;
				else
					return 0;
			}
			uint16 ToUInt16()
			{
				uint16 value;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return value;
				else
					return 0;
			}
			int64 ToInt64()
			{ 
				int64 value;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return value;
				else
					return 0;
			}
			int32 ToInt32()
			{
				int32 value;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return value;
				else
					return 0;
			}
			int16 ToInt16()
			{
				int16 value;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return value;
				else
					return 0;
			}
			float ToFloat()
			{
				float value;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return value;
				else
					return 0;
			}
			bool ToBool()
			{
				BOOL value;
				std::stringstream ss(m_szValue);
				if(ss >> value)
					return true;
				else
					return false;
			}
		};
	}
}
#endif /* __FIELD_H */